#! /bin/bash

HERE=`cd $(dirname $0); pwd -P` #脚本目录
HERE="${HERE}/"
MYLAMP="/var/local/mylamp/" #安装目录
PACKAGE="$(pwd)/package/" #安装包目录
NHIXNDIR="${MYLAMP}ngixn/" #ngixn安装目录
PHPDIR="${MYLAMP}php/" #php安装目录

if [ ! -f "${PACKAGE}nginx-1.14.2.tar.gz" ]
then
wget -P "${PACKAGE}" "http://nginx.org/download/nginx-1.14.2.tar.gz"
fi

if [ ! -d "${MYLAMP}" ]
then 
  mkdir -p  "${MYLAMP}"
fi

if [ ! -d "${PACKAGE}" ]
then
  mkdir -p "${PACKAGE}"
fi

if [ ! -d "${NHIXNDIR}" ]
then
  mkdir -p "${NHIXNDIR}"
fi

tar -zxvf "${PACKAGE}nginx-1.14.2.tar.gz" -C "${PACKAGE}" 
cd ${PACKAGE}nginx-1.14.2
./configure --prefix=${NHIXNDIR}    --with-http_ssl_module  --with-http_stub_status_module --with-pcre
make && make install


cd ${HERE}
cp ${PHPDIR}etc/php-fpm.d/www.conf.default  ${PHPDIR}etc/php-fpm.d/www.conf 
${PHPDIR}/sbin/php-fpm

rm -rf ${NHIXNDIR}/conf/nginx.conf
cp ${HERE}nginx.conf  ${NHIXNDIR}/conf/nginx.conf
















